import { ProfileData } from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

// 创建小仓库
const useUserStore = defineStore(
  'sgg_user',
  () => {
    const userProfile = ref<ProfileData>()

    const setProfile = (val: ProfileData) => {
      userProfile.value = val
    }
    const setProfileToken = (val: string) => {
      userProfile.value = { token: val }
    }

    return {
      userProfile,
      setProfile,
      setProfileToken,
    }
  },
  { persist: true },
)
// 对外暴露小仓库
export default useUserStore
